using System;

namespace Taste {

class Taste {

	public static void Main (string[] arg) {
		if (arg.Length > 0) {
			Errors.SemErr = new ErrorProc(SemErr);
			Errors.fileName = arg[0];
			Scanner.Init(arg[0]);
			Parser.Parse();
			Errors.Summarize(arg[0]);
			if (Errors.count == 0) TC.Interpret();
		} else
			Console.WriteLine("-- No source file specified");
	}
	
	static void SemErr (int n, int line, int col) {
		Errors.count++;
		string s;
		switch (n) {
			case 1: s = "name declared twice"; break;
			case 2: s = "undeclared name"; break;
			case 3: s = "name does not match procedure or program name"; break;
			case 4: s = "integer type expected"; break;
			case 5: s = "incompatible types"; break;
			case 6: s = "boolean type expected"; break;
			case 7: s = "procedure used as a variable"; break;
			case 8: s = "called object is not a procedure"; break;
			case 9: s = "program too long"; break;
			default:s = "semantic error " + n; break;
		}
		Errors.StoreError(n, line, col, s);
	}

}

} // end namespace


